<template>
    <div>
      <AplidForm
        ref="formRef"
        v-bind="BaseFormConfig"
        v-model="formModel"
        @submit="onSubmit">
      </AplidForm>
    </div>
  </template>
  
  <script setup lang="ts">
  import apiMod from '@/apiMod/index'
  import { BaseFormConfig } from '../config'
  // import { useCommonStore } from '@/stores/common'
  import { getAreaObj } from '@/utils/util'
  import {EncodeUtf8} from '@/views/oneStopOffice/utils/index'
  let emit = defineEmits(['refresh'])
  import { useRoute } from 'vue-router';
  const route = useRoute()
  // import { useOperate } from '@/views/datacenter/hooks/useConfig'

  type Props = {
    nowRowData?:any
    module?:number|string
  }
  let props = withDefaults(defineProps<Props>(),{
    nowRowData:{},
    module:1
  })

  let formRef = ref()
  let formModel = ref()
  const onSubmit = (form, done) => {
    const areasObj: any = getAreaObj(form.areas, 'from')
			const areasNameObj: any = getAreaObj(form.areasName, 'from')
			if(form.infoKeywords){
				form.infoKeywords = form.infoKeywords.join(',')
			}
			if(form.infoContent){
				form.infoContent = EncodeUtf8(form.infoContent)
			}
			const params = {
				...form,
				module:props.module==1?1:props.module==2?2:undefined,
				moduleLabel:props.module==1?'一站办':props.module==2?'安全监管':undefined,
				...areasObj,
				...areasNameObj,
				areas: undefined,
				areasName: undefined,
				code: 3005,
			}
       // 输入框都进行一下加密
       BaseFormConfig.column.forEach(el=>{
        if((!el.type||el.type=='input'||el.type=="text")&& params[el.prop]){
          params[el.prop] =  EncodeUtf8(params[el.prop])
        }
      })
    apiMod.view_dpNewsInfo_gather(params).then(res=>{
      done()
      emit('refresh')
    })
  }
  const onSave = () => {
    formRef.value!.onSubmit()
  }
  defineExpose({
    onSave
  })
  </script>
  
  <style scoped></style>
  